﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Calendar;
using BussinesLayer.Appointments;
using ViewLayer.Patients;
using ViewLayer.Properties;
using BussinesLayer.Patients;
using BussinesLayer;
using BussinesLayer.MainView;
using ModelLayer.Appointments;
using ModelLayer;
using ViewLayer.MessageConfiguration;
using ViewLayer.UserConfiguration;
using System.Diagnostics;
using System.IO;

namespace ViewLayer
{
    public partial class MainViewForm : Form
    {
        MedAgendaEntities entities = new MedAgendaEntities();
        AppointmentRegistrationController appointmentController;
        bool vistaDiaria = false;
        private string url = "";

        object senderFlag;
        ToolStripItemClickedEventArgs eFlag;

        public MainViewForm()
        {
            bool firstUse = false;
            //mensaje de configuracion inicial de usuario
            var user = (from u in entities.User_
                        select u).SingleOrDefault();
            if (user == null)
            {
                UserConfigurationForm userConfiguration = new UserConfigurationForm();
                userConfiguration.ShowDialog();
                firstUse = true;
            }

            InitializeComponent();
            panelPatientInformation.Visible = false;
            appointmentController = new AppointmentRegistrationController();
            //calendar scrollbar  set to center
            ((DayView)userControlCalendar.Controls["dayViewCalendar"]).Scrollbar.Value = (((DayView)userControlCalendar.Controls["dayViewCalendar"]).StartHour * 3 * ((DayView)userControlCalendar.Controls["dayViewCalendar"]).AppointmentSlotHeight);

            ChangeColorAndUpdateVisit(senderFlag, eFlag);
            comboBoxDuration.Text = "30";
            InternetConnection.BeginInternetConnectionCheck();
            
            //Mensaje por defecto
            var message = (from m in entities.Message_
                           select m).SingleOrDefault();
            if (message == null)
            {
                Message_ m = new Message_();
                m.OID_ = Guid.NewGuid();
                m.Message_1 = "Usted tiene una consulta con el doctor " + user.UserName_;
                m.Option_ = "Una hora antes de la cita";
                entities.Message_.AddObject(m);
                entities.SaveChanges();
            }

            ////direccionamiento a pagina por defecto, si es primer uso
            //if (firstUse)
            //{
            //    webBrowserRight.Url = new Uri("http://www.medsoft.com.bo");
            //    webBrowserTop.Url = new Uri("http://www.medsoft.com.bo");
            //}
            //else
            //{
            //    string topUrl = "http://www.medsoft.com.bo" + "/top" + user.OID_.ToString();
            //    string rightUrl = "http://www.medsoft.com.bo" + "/right" + user.OID_.ToString();
            //    webBrowserTop.Url = new Uri(topUrl);
            //    webBrowserRight.Url = new Uri(rightUrl);
            //}

            //solo para la demo
            string demoUrl = Path.Combine(Directory.GetCurrentDirectory(), "demoUrlFile.html");
            string demoUrl1 = Path.Combine(Directory.GetCurrentDirectory(), "demoUrlFile1.html");
            webBrowserRight.Url = new Uri(demoUrl1);
            webBrowserTop.Url = new Uri(demoUrl);
        }   

        private void MainViewForm_Load(object sender, EventArgs e)
        {
            sex_ComboBox.DataSource = (from s in entities.SexEnum_ select s.Code_).ToList();
            cmbPatientType.DataSource = (from p in entities.PatientTypeEnum_ where p.Deactivated_.Equals(false) select p.Value_).ToList();
            cmbPatientType.SelectedItem = "Sin especificar";
            radAppointment.Checked = true;

            Process pr = new Process();
            pr = Process.GetCurrentProcess();
        }

        private void EnableQuickPatientsControls()
        {
            groupBoxVisitProperties.Enabled = false;
            buttonSearchPatient.Enabled = false;
            buttonNewPatient.Enabled = false;
            checkBoxVipPatient.Enabled = true;
            txtMrnId.Enabled = true;
            txtFamilyName.Enabled = true;
            txtGivenName.Enabled = true;
            txtMiddleName.Enabled = true;
            txtMobilePhone.Enabled = true;
            txtPhoneNumber.Enabled = true;
            sex_ComboBox.Enabled = true;
            dateOfBirth_DateTimePicker.Enabled = true;
            txtEmail.Enabled = true;
            cmbPatientType.Enabled = true;
            buttonAddQuickPatient.Visible = true;
            buttonCancelQuickPatient.Visible = true;
            txtMrnId.Focus();
        }

        private void DisableQuickPatientsControls()
        {
            groupBoxVisitProperties.Enabled = true;
            buttonSearchPatient.Enabled = true;
            buttonNewPatient.Enabled = true;
            checkBoxVipPatient.Enabled = false;
            txtMrnId.Enabled = false;
            txtFamilyName.Enabled = false;
            txtGivenName.Enabled = false;
            txtMiddleName.Enabled = false;
            txtMobilePhone.Enabled = false;
            txtPhoneNumber.Enabled = false;
            sex_ComboBox.Enabled = false;
            dateOfBirth_DateTimePicker.Enabled = false;
            txtEmail.Enabled = false;
            cmbPatientType.Enabled = false;
            buttonAddQuickPatient.Visible = false;
            buttonCancelQuickPatient.Visible = false;
            buttonSearchPatient.Focus();
        }

        private void ClearQuickPatientsFields()
        {
            checkBoxVipPatient.Checked = false;
            txtMrnId.Clear();
            txtFamilyName.Clear();
            txtGivenName.Clear();
            txtMiddleName.Clear();
            txtMobilePhone.Clear();
            txtPhoneNumber.Clear();
            sex_ComboBox.SelectedIndex = 0;
            dateOfBirth_DateTimePicker.Refresh();
            txtEmail.Clear();
            cmbPatientType.SelectedItem = "Sin especificar";
        }

        private void toolStripButtonNewPatient1_Click(object sender, EventArgs e)
        {
            SearchPatientView patientView = new SearchPatientView(1);
            patientView.ShowDialog();
        }

        private void toolStripButtonView1_Click(object sender, EventArgs e)
        {
            if (((DayView)userControlCalendar.Controls["dayViewCalendar"]).DaysToShow == 7)
            {
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).DaysToShow = 1;
                toolStripButtonView1.Image = Resources.CalendarWeek;
                toolStripButtonView1.ToolTipText = "Ver agenda en vista semanal.";

                vistaDiaria = true;
            }
            else
            {
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).DaysToShow = 7;
                toolStripButtonView1.Image = Resources.CalendarDay;
                toolStripButtonView1.ToolTipText = "Ver agenda en vista diaria.";
                vistaDiaria = false;
            }
        }

        private void buttonPreviousMonth_Click(object sender, EventArgs e)
        {
            if (!vistaDiaria)
            {
                dateTimePickerStartDate.Value = dateTimePickerStartDate.Value.AddMonths(-1);
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).StartDate = dateTimePickerStartDate.Value;
                ChangeColorAndUpdateVisit(senderFlag, eFlag);
            }
            else
            {
                dateTimePickerStartDate.Value = dateTimePickerStartDate.Value.AddDays(-7);
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).StartDate = dateTimePickerStartDate.Value;
                ChangeColorAndUpdateVisit(senderFlag, eFlag);
            }
        }

        private void buttonPreviousWeek_Click(object sender, EventArgs e)
        {
            if (!vistaDiaria)
            {
                dateTimePickerStartDate.Value = dateTimePickerStartDate.Value.AddDays(-7);
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).StartDate = dateTimePickerStartDate.Value;
                ChangeColorAndUpdateVisit(senderFlag, eFlag);
            }
            else
            {
                dateTimePickerStartDate.Value = dateTimePickerStartDate.Value.AddDays(-1);
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).StartDate = dateTimePickerStartDate.Value;
                ChangeColorAndUpdateVisit(senderFlag, eFlag);
            }
        }

        private void buttonToday_Click(object sender, EventArgs e)
        {
            dateTimePickerStartDate.Value = dateTimePickerStartDate.Value = DateTime.Today;
            ((DayView)userControlCalendar.Controls["dayViewCalendar"]).StartDate = dateTimePickerStartDate.Value;
            RefreshNavigator();
        }

        private void buttonNextWeek_Click(object sender, EventArgs e)
        {
            if (!vistaDiaria)
            {
                dateTimePickerStartDate.Value = dateTimePickerStartDate.Value.AddDays(7);
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).StartDate = dateTimePickerStartDate.Value;
                ChangeColorAndUpdateVisit(senderFlag, eFlag);
            }
            else
            {
                dateTimePickerStartDate.Value = dateTimePickerStartDate.Value.AddDays(1);
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).StartDate = dateTimePickerStartDate.Value;
                ChangeColorAndUpdateVisit(senderFlag, eFlag);
            }
        }

        private void buttonNextMonth_Click(object sender, EventArgs e)
        {
            if (!vistaDiaria)
            {
                dateTimePickerStartDate.Value = dateTimePickerStartDate.Value.AddMonths(1);
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).StartDate = dateTimePickerStartDate.Value;
                ChangeColorAndUpdateVisit(senderFlag, eFlag);
            }
            else
            {
                dateTimePickerStartDate.Value = dateTimePickerStartDate.Value.AddDays(7);
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).StartDate = dateTimePickerStartDate.Value;
                ChangeColorAndUpdateVisit(senderFlag, eFlag);
            }
        }

        private void buttonPreviousMonth_MouseHover(object sender, EventArgs e)
        {
            if (vistaDiaria)
                toolTipText.SetToolTip(buttonPreviousMonth, "Semana anterior");
            else
                toolTipText.SetToolTip(buttonPreviousMonth, "Mes anterior");
        }

        private void buttonPreviousWeek_MouseHover(object sender, EventArgs e)
        {
            if (vistaDiaria)
                toolTipText.SetToolTip(buttonPreviousWeek, "Día anterior");
            else
                toolTipText.SetToolTip(buttonPreviousWeek, "Semana anterior");
        }

        private void buttonNextWeek_MouseHover(object sender, EventArgs e)
        {
            if (vistaDiaria)
                toolTipText.SetToolTip(buttonNextWeek, "Siguiente día");
            else
                toolTipText.SetToolTip(buttonNextWeek, "Siguiente semana");
        }

        private void buttonNextMonth_MouseHover(object sender, EventArgs e)
        {
            if (vistaDiaria)
                toolTipText.SetToolTip(buttonNextMonth, "Siguiente semana");
            else
                toolTipText.SetToolTip(buttonNextMonth, "Siguiente mes");
        }

        private void MainViewForm_KeyUp(object sender, KeyEventArgs e)
        {
            if (!panelPatientInformation.Visible)
            {
                if (e.KeyCode.Equals(Keys.Left))
                {
                    buttonPreviousWeek_Click(sender, e);
                }
                if (e.KeyCode.Equals(Keys.Right))
                {
                    buttonNextWeek_Click(sender, e);
                }
            }
        }

        private void buttonSearchPatient_Click(object sender, EventArgs e)
        {
            SearchPatientView search = new SearchPatientView(0);
            search.ShowDialog();
            if (!string.IsNullOrEmpty(AgendaPatientController.currentPID))
            {
                var patient = entities.PatientProfile_.Where(x => x.MrnId_.Equals(AgendaPatientController.currentPID)).Single();
                checkBoxVipPatient.Checked = (bool)patient.VipPatient_;
                txtMrnId.Text = patient.IdDocumentNumber_;
                txtFamilyName.Text = patient.FamilyName_;
                txtGivenName.Text = patient.GivenName_;
                txtMiddleName.Text = patient.MiddleName_;
                txtMobilePhone.Text = patient.PatientProfileTelephoneNumber_.Where(x => x.PatientProfile__OID_.Equals(patient.OID_) && x.TelephoneEquipmentEnum__Code_.Equals("CP")).First().Number_;
                txtPhoneNumber.Text = patient.PatientProfileTelephoneNumber_.Where(x => x.PatientProfile__OID_.Equals(patient.OID_) && x.TelephoneEquipmentEnum__Code_.Equals("PH")).First().Number_;
                sex_ComboBox.SelectedItem = patient.SexEnum__Code_;
                dateOfBirth_DateTimePicker.Text = patient.DateOfBirth_.ToString();
                txtEmail.Text = patient.PatientProfileEmailAddress_.Where(x => x.PatientProfile__OID_.Equals(patient.OID_)).First().Address_;
                cmbPatientType.SelectedItem = patient.PatientTypeEnum_.Value_;
            }
        }

        private void buttonNewPatient_Click(object sender, EventArgs e)
        {
            ClearQuickPatientsFields();
            EnableQuickPatientsControls();
        }

        private void buttonAddQuickPatient_Click(object sender, EventArgs e)
        {
            if (Validator.validateAddQuiekPatient(txtFamilyName, txtGivenName) != "-1")
            {
                if (Validator.validateAddQuiekPatient(txtFamilyName, txtGivenName) != "-2")
                {
                    if (Validator.validateAddQuiekPatient(txtFamilyName, txtGivenName) != "-3")
                    {
                        AgendaPatientController.currentPID = AgendaPatientController.CreateTempPatient(checkBoxVipPatient.Checked, txtMrnId.Text, txtFamilyName.Text, txtGivenName.Text, txtMiddleName.Text, txtMobilePhone.Text, txtPhoneNumber.Text, sex_ComboBox.SelectedValue.ToString(), dateOfBirth_DateTimePicker.Value.ToString(), txtEmail.Text, cmbPatientType.SelectedValue.ToString());
                        DisableQuickPatientsControls();
                    }
                    else
                    {
                        MessageBox.Show(null, "El valor en el campo \"nombre\" es inválido.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtGivenName.Clear();
                    }
                }
                else
                {
                    MessageBox.Show(null, "El valor en el campo \"apellidos\" es inválido.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtFamilyName.Clear();
                }
            }
            else
                MessageBox.Show(null, "Ingrese los campos obligatorios.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

        }

        private void buttonCancelQuickPatient_Click(object sender, EventArgs e)
        {
            DisableQuickPatientsControls();
        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (txtFamilyName.Text != string.Empty && txtGivenName.Text != string.Empty)
            {
                if (radAppointment.Checked || (radReminder.Checked && txtMobilePhone.Text != string.Empty))
                {
                    if (AppointmentRegistrationController.isNewAppointment)
                    {
                        string visitID = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();

                        if (!checkBoxManual.Checked)
                            appointmentController.CreateVisit(Guid.Parse(appointmentController.GetPatientOID(AgendaPatientController.currentPID, txtFamilyName.Text, txtGivenName.Text)), visitID, DateTime.Parse(labelApointmentDate.Text + " " + horaEntradaLabel.Text), DateTime.Parse(labelApointmentDate.Text + " " + horaSalidaLabel.Text), visitID, textBoxPurpose.Text, radAppointment.Checked);
                        else
                        {
                            DateTime startTime = DateTime.Parse(labelApointmentDate.Text + " " + labelStart.Text + comboBoxMinutes.Text + " " + labelTT.Text);
                            DateTime endTime = startTime.AddMinutes(Double.Parse(comboBoxDuration.Text));

                            appointmentController.CreateVisit(Guid.Parse(appointmentController.GetPatientOID(AgendaPatientController.currentPID, txtFamilyName.Text, txtGivenName.Text)), visitID, startTime, endTime, visitID, textBoxPurpose.Text, radAppointment.Checked);
                            checkBoxManual.Checked = false;
                        }
                        AppointmentManager.Appointments[AppointmentManager.Appointments.Count - 1].AppointmentId = visitID;
                        AppointmentManager.Appointments[AppointmentManager.Appointments.Count - 1].Subject = "Nombre: " + txtFamilyName.Text + " " + txtGivenName.Text + "\nPID: " + txtMrnId.Text + "\nEstado: " + "Pendiente";
                        AppointmentManager.Appointments[AppointmentManager.Appointments.Count - 1].Color = Color.LightPink;
                        AppointmentManager.Appointments[AppointmentManager.Appointments.Count - 1].BorderColor = Color.LightPink;
                        AppointmentManager.Appointments[AppointmentManager.Appointments.Count - 1].Locked = true;
                    }
                    else
                    {
                        if (!checkBoxManual.Checked)
                            appointmentController.ModifyAppointment(Guid.Parse(appointmentController.GetPatientOID(AgendaPatientController.currentPID, txtFamilyName.Text, txtGivenName.Text)), AppointmentRegistrationController.accessionNumberSelected, DateTime.Parse(labelApointmentDate.Text + " " + horaEntradaLabel.Text), DateTime.Parse(labelApointmentDate.Text + " " + horaSalidaLabel.Text), AppointmentRegistrationController.accessionNumberSelected, textBoxPurpose.Text, radAppointment.Checked);
                        else
                        {
                            DateTime startTime = DateTime.Parse(labelApointmentDate.Text + " " + labelStart.Text + comboBoxMinutes.Text + " " + labelTT.Text);
                            DateTime endTime = startTime.AddMinutes(Double.Parse(comboBoxDuration.Text));

                            appointmentController.ModifyAppointment(Guid.Parse(appointmentController.GetPatientOID(AgendaPatientController.currentPID, txtFamilyName.Text, txtGivenName.Text)), AppointmentRegistrationController.accessionNumberSelected, startTime, endTime, AppointmentRegistrationController.accessionNumberSelected, textBoxPurpose.Text, radAppointment.Checked);
                            checkBoxManual.Checked = false;
                        }
                    }
                }
                else
                {
                    MessageBox.Show(null, "Ingrese el número de celular.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).Invalidate();
                ClearAllFillsOfNewVisit();
                ChangeColorAndUpdateVisit(senderFlag, eFlag);
            }
            else
                MessageBox.Show(null, "Ingrese un paciente.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        private void buttonNoAcept_Click(object sender, EventArgs e)
        {
            ClearAllFillsOfNewVisit();
            panelPatientInformation.Visible = false;
            groupBoxVisitProperties.Enabled = true;
            groupBoxPatientInformation.Enabled = true;
            buttonNewPatient.Enabled = true;
            AppointmentManager.Appointments.RemoveAt(AppointmentManager.Appointments.Count - 1);
            RefreshNavigator();
        }

        private void ClearAllFillsOfNewVisit()
        {
            AgendaPatientController.currentPID = "";
            ClearQuickPatientsFields();
            textBoxPurpose.Text = string.Empty;
            panelPatientInformation.Visible = false;
            radAppointment.Checked = true;
        }

        private void ChangeColorAndUpdateVisit(object sender, ToolStripItemClickedEventArgs e)
        {
            senderFlag = sender;
            eFlag = e;
            if (AppointmentRegistrationController.logTime == 1)
            {
                ClearAllFillsOfNewVisit();
                panelPatientInformation.Visible = false;
                groupBoxVisitProperties.Enabled = true;
                groupBoxPatientInformation.Enabled = true;
                if (AppointmentManager.Appointments.Count > 0)
                    AppointmentManager.Appointments.RemoveAt(AppointmentManager.Appointments.Count - 1);
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).Invalidate();
            }
            RefreshNavigator();
        }

        private void RefreshNavigator()
        {
            List<VisitModelView> arrayVisit = appointmentController.SelectAppointments(this.dateTimePickerStartDate.Value, this.dateTimePickerStartDate.Value.AddDays(6));

            if (arrayVisit.Count != 0)
            {
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).StartDate = dateTimePickerStartDate.Value;
                Appointment appointment;

                AppointmentManager.Appointments.Clear();
                foreach (VisitModelView actual in arrayVisit)
                {
                    appointment = new Appointment();
                    appointment.AppointmentId = actual.AccessionNumber;
                    appointment.PatientOID = actual.PatientOID;
                    appointment.StartDate = actual.AdmitTime;
                    appointment.EndDate = actual.DischargeTime;
                    if (actual.IsAppointment)

                        appointment.Subject = "Nombre: " + actual.FamilyName + " " + actual.GivenName + "\nPID: " + actual.MrnID + "\nTipo cita: " + actual.Priority + "\nRazón de estudio: " + actual.ReasonForStudy + "\nFecha de nacimiento: " + actual.DateOfBirth.ToShortDateString() + "\nTelefono: " + actual.Telephone + "\nCelular: " + actual.MobileNumber;
                    else
                        appointment.Subject = "Nombre: " + actual.FamilyName + " " + actual.GivenName + "\nMensaje a enviar: " + actual.ReasonForStudy + "\nCelular: " + actual.MobileNumber + "\nTelefono: " + actual.Telephone;

                    appointment.PatientOID = actual.PatientOID;

                    if (actual.Status == "Pendiente")
                    {
                        if (actual.IsAppointment)
                        {
                            appointment.Color = Color.LightPink;
                            appointment.BorderColor = Color.DeepPink;
                        }
                        else
                        {
                            appointment.Color = Color.LightGreen;
                            appointment.BorderColor = Color.Green;
                        }
                        appointment.Locked = true;
                    }
                    if (actual.Status == "Admitido")
                    {
                        appointment.Color = Color.LightBlue;
                        appointment.BorderColor = Color.CadetBlue;
                        appointment.Locked = true;
                    }
                    if (actual.Status == "Cancelado")
                    {
                        appointment.Color = Color.Gray;
                        appointment.BorderColor = Color.Black;
                        appointment.Locked = true;
                    }
                    AppointmentManager.Appointments.Add(appointment);
                }

                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).Invalidate();
            }
            else
            {
                AppointmentManager.Appointments.Clear();
                ((DayView)userControlCalendar.Controls["dayViewCalendar"]).Invalidate();
            }
        }

        private void checkBoxManual_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxManual.Checked == true)
            {
                panelManual.Visible = true;
                labelStart.Text = horaEntradaLabel.Text.Split(':').GetValue(0).ToString() + ":";
                try
                {
                    labelTT.Text = horaEntradaLabel.Text.Split(' ').GetValue(1).ToString();
                }
                catch
                {
                    labelTT.Text = string.Empty;
                    labelTT.Visible = false;
                }
                comboBoxMinutes.Text = horaEntradaLabel.Text.Split(':').GetValue(1).ToString().Split(' ').GetValue(0).ToString();
            }
            else
            {
                panelManual.Visible = false;
            }
        }

        private void radioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (radAppointment.Checked)
            {
                labelPurpose.Text = "razón de estudio/visita";
                checkBoxManual.Visible = true;
                labelEndTime.Visible = true;
                labelStartTime.Visible = true;
                horaSalidaLabel.Visible = true;
            }
            if (radReminder.Checked)
            {
                labelPurpose.Text = "mensaje a enviar";
                checkBoxManual.Checked = false;
                checkBoxManual.Visible = false;
                labelEndTime.Visible = false;
                labelStartTime.Visible = false;
                horaSalidaLabel.Visible = false;
            }
        }

        private void toolStripButtonConfiguration_Click(object sender, EventArgs e)
        {
            MessageConfigurationForm messageconfiguration = new MessageConfigurationForm();
            messageconfiguration.Show();

        }

        private void toolStripButtonHelp_Click(object sender, EventArgs e)
        {

        }

        private void toolStripButtonRecharge_Click(object sender, EventArgs e)
        {

        }
    }
}
